package live.yanxiaohui.demo.topic;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import live.yanxiaohui.demo.util.RabitMQConnection;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class Producer {

    private static final String EXCHANGE_NAME = "exchange_demo3";

    public static void main(String[] args) throws IOException, TimeoutException {
        // 1.创建连接
        Connection connection = RabitMQConnection.getConnection();
        // 2.设置通道
        Channel channel = connection.createChannel();
        // 3.设置消息
        String msg = "topic模式";
        System.out.println("msg:" + msg);
        channel.basicPublish(EXCHANGE_NAME, "yxh.2131.2131.asd", null, msg.getBytes());
        channel.close();
        connection.close();
    }
}
